package com.yycx.module.bus.provider.handler.common;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.module.bus.client.entity.BusDrugs;
import com.yycx.module.bus.client.entity.BusSupplier;
import com.yycx.module.system.client.entity.SysCompany;
import com.yycx.module.system.client.entity.SysOrganization;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 商品列表
 *
 * @author zyf
 */
@Component
public class BusDrugsPageListHandler implements PageInterceptor<BusDrugs> {


    @Override
    public ResultBody validate(CriteriaQuery cq, EntityMap params) {
        return ResultBody.ok();
    }

    @Override
    public void prepare(CriteriaQuery cq, PageParams pageParams, EntityMap params) {
        cq.eq(BusDrugs.class, "companyId", OpenHelper.getCompanyId());
        cq.addSelect(SysCompany.class, "companyName");
        cq.addSelect(SysOrganization.class, "organizationName");
        cq.addSelect(BusSupplier.class, "supplierName");
        cq.createJoin(SysOrganization.class);
        cq.createJoin(SysCompany.class);
        cq.createJoin(BusSupplier.class);
        cq.eq(BusDrugs.class, "companyId", OpenHelper.getCompanyId());
    }

}
